/**
 * storage 储存对象
 * @param {*} key 
 * @param {*} obj 对象
 */
 function storageSet(key, obj, storage="localStorage") {
  if (obj) {
      var save = JSON.stringify(obj);
      window[storage].setItem(key, save);
  }
}

/**
* storage 获取对象
* @param {*} key 
*/
function storageGet(key, storage="localStorage") {
  var out = null;
  if (key) {
      var data = window[storage].getItem(key);
      if (data) {
          out = JSON.parse(data);
      }
  }
  return out;
}

/**
* storage 删除对象
* @param {*} key 
*/
function storageDel(key, storage="localStorage") {
  if (window[storage][key]) {
    window[storage].removeItem(key);
  }
}
export {
  storageGet,
  storageSet,
  storageDel
};
